package com.jyb.controller;

import java.util.ArrayList;
import java.util.List;

import com.jfinal.core.Controller;
import com.jyb.model.MyOrder;
import com.jyb.model.QueryLog;
import com.jyb.util.StringUtils;
import com.jyb.util.capture.HgfxUtil;
import com.jyb.vo.HgfxVo;
import com.jyb.vo.UserVo;

public class HgfxController extends Controller{

	public void index(){
		
		String tdh=getPara("tdh");
		List<HgfxVo> vos=new ArrayList<HgfxVo>();
		if(!StringUtils.isEmpty(tdh)){
			tdh=tdh.trim();
			vos=HgfxUtil.capture(tdh);
		}
		
		setAttr("tdh", tdh);
		setAttr("vos", vos);
		
		UserVo userVo=(UserVo)getSession().getAttribute("user");
		if(userVo!=null){
			for (HgfxVo hgfxVo : vos) {
				MyOrder.dao.updateMyOrder(userVo.getId(), tdh, hgfxVo.getCm(), hgfxVo.getHc());
			}
		}
		
		if(userVo!=null&&vos.size()>0){
			QueryLog.dao.addOrUpdate(userVo.getId(), "1", tdh);
		}
		
		setAttr("nav", "hgfx");
		renderJsp("/views/hgfx/index.jsp");
	}
}
